package com.baicaoyuan.web.repository;


import com.baicaoyuan.web.model.StockInDO;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import javax.transaction.Transactional;
import java.math.BigDecimal;
import java.util.List;

/**
 * 功能描述：需求发布
 *
 * @author 罗富祥
 * 创建时间： 2018/1/4
 * 版权：
 */
@Repository
public interface StockInRepository extends JpaRepository<StockInDO, Long> {

    /**
     * 获取申请列表
     *
     * @return
     */
    @Query(value = "select * from t_stock_in where user_id_fk = ?1 order by in_time desc ", nativeQuery = true)
    List<StockInDO> getStockIn(Long userId);

    Integer countAllByUserIdIs(Long userId);

    @Transactional
    @Modifying
    @Query(value = "delete  from t_stock_in  where user_id_fk = ?1", nativeQuery = true)
    Integer deleteByUserIdFk(Long userId);
}
